package com.yricky.memoria.ui.component

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.yricky.memoria.data.pojo.PdfQuery
import com.yricky.memoria.utils.PdfDoc
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

/**
 * @author Yricky
 * @date 2021/12/11
 */
class PdfViewModel:ViewModel() {

    fun setPdf(query: PdfQuery,doc:PdfDoc){
        _viewState.value = _viewState.value.copy(
            title = query.pdfName,
            query = query,
            doc = doc
        )
    }

    data class ViewState(
        val query: PdfQuery? = null,
        val title:String = "",
        val doc:PdfDoc? = null
    )
    private val _viewState:MutableStateFlow<ViewState> = MutableStateFlow(ViewState())
    val viewState = _viewState.asStateFlow()


}